<template>
  <el-dialog title="添加学生" :visible.sync="dialogFormVisible" :before-close="closeForm">
    <el-form :model="form">
      <el-form-item label="学生姓名" :label-width="formLabelWidth">
        <el-input v-model="form.name" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="学号" :label-width="formLabelWidth">
        <el-input v-model="form.studentId" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="closeForm">取 消</el-button>
      <el-button type="primary" @click="pushStudent">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
//todo 2021/6/14 表单验证
export default {
  name: "AddStudentFrom",
  props:{
    dialogFormVisible:Boolean
  },
  data() {
    return {
      form: {
        studentId: '',
        name:'',
      },
      formLabelWidth: '120px',
    };
  },
  methods: {
    pushStudent() {
      this.$emit('push', this.form)
      this.form={}
      this.closeForm()
    },
    closeForm(){
      this.$emit('close',false)
      console.log('正在关闭')
    }
  },
}
</script>

<style scoped>

</style>